import 'JvtdStringLocalized.dart';
export 'JvtdStringLocalized.dart';
export 'JvtdStringBase.dart';
import 'JvtdStringBase.dart';
import 'package:flutter/material.dart';
export 'JvtdStringLocalizedDelegate.dart';
import 'package:redux/redux.dart';
import '../rudex/JvtdState.dart';
import '../rudex/JvtdLocaleReducer.dart';

enum JvtdStringType{
  ZH,
  EN
}

class JvtdString{
  static const String ZH = 'zh';//中文
  static const String CH = 'CH';
  static const String EN = 'en';//英文
  static const String US = 'US';

  //获取当前语言包
  static JvtdStringBase getLocale(BuildContext context){
    return JvtdStringLocalized.of(context).currentLocalized;
  }

  //切换语言包
  static void changeLocale(Store<JvtdState> store, JvtdStringType type) {
    Locale locale = store.state.platformLocale;
    switch (type) {
      case JvtdStringType.ZH:
        locale = Locale(JvtdString.ZH,JvtdString.CH);
        break;
      case JvtdStringType.EN:
        locale = Locale(JvtdString.EN,JvtdString.US);
        break;
    }
    store.dispatch(RefreshLocaleAction(locale));
  }
}